import java.util.Scanner;

/**
 * A class to calculate the power of a number using the fast exponentiation algorithm.
 * This class provides methods to compute \( x \) raised to the power of \( y \) efficiently.
 * It supports both integer and floating-point numbers.
 */
public class Power {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入底数 x: ");
        double x = scanner.nextDouble();
        System.out.print("请输入指数 y: ");
        int y = scanner.nextInt();

        double result = power(x, y);
        System.out.println(x + " 的 " + y + " 次方是: " + result);
    }

    public static double power(double x, int y) {
        if (y == 0) {
            return 1;
        } else if (y > 0) {
            return x * power(x, y - 1);
        } else {
            return 1 / power(x, -y);
        }
    }
}